﻿using BCCommon;
using BCData.OA.Workflow.WorkflowActivity;
using BCDto.OA.Workflow.Template.WorkflowActivity;
using BCService.Utils;
using System;
using System.Collections.Generic;
using System.Text;

namespace BCService.OA.Workflow.Template.WorkflowActivity
{
    public class WorkflowActivityService : IWorkflowActivityService
    {
        private readonly IWorkflowActivityData workflowActivityData;

        public WorkflowActivityService(IWorkflowActivityData workflowActivityData)
        {
            this.workflowActivityData = workflowActivityData;
        }

        public PageableList<WorkflowActivityDto> Query(long? workflowCategoryId, string workflowName, bool? isBaseWorkflow, int pageIndex, int pageSize)
        {
            var (list, count) = this.workflowActivityData.Query(workflowCategoryId, workflowName, isBaseWorkflow, pageIndex, pageSize).GetAwaiter().GetResult();

            return new PageableList<WorkflowActivityDto>
            {
                Items = list.As<IEnumerable<WorkflowActivityDto>>(),
                Count = count,
                PageIndex = pageIndex,
                PageSize = pageSize
            };
        }
    }
}
